<%@ page language="java" contentType="text/html; charset=UTF-8" import="com.book.model.Type" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title><spring:message code="html.addpage.title"/></title>
<style type="text/css">
<!--
* {
	font-family: Verdana;
	font-size: 12px;
}

body {
	background: #fff;
	color: #000;
}
-->
</style>
<script language="javascript">
function add()
{
	if(checkConditions())
	{
		document.getElementById("bookForm").submit();
	}
}


function checkConditions()
{
	if(document.getElementById("title").value=="")
  	{
    	alert("请输入标题");
    	document.bookForm.title.focus();
    	return false;
  	}
	if(document.getElementById("author").value=="")
  	{
    	alert("请输入作者");
    	document.bookForm.author.focus();
    	return false;
  	}
	if(document.getElementById("fileData").value=="")
  	{
    	alert("您还没有上传文件");
    	document.bookForm.path.focus();
    	return false;
  	}
	return true;
}

function FileUpload_onselect()
        {
            var path;
            path=document.getElementById("fileData").value;      //C:\Documents and Settings\hud\AddFile.jpg
            var split;
            split=path.split('\\'); 
            var name=split[split.length-1];             
            document.getElementById("title").value=name.split('.')[0];  //AddFile result
        }
</script>
</head>
<body>
<%
String filePath=(String)request.getAttribute("filePath");
if(filePath==null){filePath="";}
Type type=(Type)request.getAttribute("type");
%>
<br> 
<table align="center" width="800">

<form:form  method="POST" name="bookForm" id="bookForm" action="addPage.do"  commandName="bookForm" enctype="multipart/form-data">
		<tr>
			<td align="center" height="29" valign="middle">
				<p>
                    <form:label for="fileData" path="fileData"><spring:message code="book.form.fileData.lable"/></form:label> 
                    <form:input path="fileData" type="file" onchange="return FileUpload_onselect()"/>
                <p>
				<spring:message code="book.form.title.lable"/>:&nbsp; 
			<input type="text" id="title" name="title" size="12" value="<%=filePath %>" />
			<p>&nbsp;&nbsp; 
			<spring:message code="book.form.author.lable"/>:&nbsp; 
			<input type="text" id="author" name="author" size="12" value="" />&nbsp;&nbsp; 
<p>
				<%=type.getBigtype1()%>:&nbsp;
				<form:select path="type1"  multiple="true"  cssStyle="height:60px" >
					<form:options items="${type.type1s}"  itemValue="id" itemLabel="name"  />
				</form:select>
			<p>	
					<%=type.getBigtype2()%>:&nbsp;
				<form:select path="type2"  multiple="true"  cssStyle="height:60px" >
					<form:options items="${type.type2s}"  itemValue="id" itemLabel="name"  />
				</form:select>
			<p>		
					<%=type.getBigtype3()%>:&nbsp;
				<form:select path="type3"  multiple="true"  cssStyle="height:60px" >
					<form:options items="${type.type3s}" itemValue="id" itemLabel="name" />
				</form:select>
				
				 <p>

				
				<input type="button"  value=<spring:message code="book.form.submit.lable"/>  onclick="add()"/>	  </td>
		</tr>
	
</form:form>
</table>

</body>
</html>
